Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Using the Standard Sound Dialog Component

To work with the standard sound dialog component, it is necessary to open a connection to the component using the Component Manager. An example of how to do this is shown in Listing 1 .

Listing 1 Opening a connection to the standard sound dialog component

ComponentInstance ci;
ci = OpenDefaultComponent(StandardCompressionType,
        StandardCompressionSubTypeSound);

After obtaining a connection to the standard sound dialog component, it may be appropriate to configure the dialog box to present a reasonable set of values. This is done with SCSetInfo as shown in Listing 2 . This example sets the sample rate to 32000 Hz, the sample size to 8 bits, the channel count to 1, and the compression format to MACE 6:1. If SCSetInfo is not called for a given parameter, that parameter defaults to an appropriate value.

Listing 2 Setting initial values for the dialog box

UnsignedFixed   rate;
short           sSize, cCount;
OSType          compType;
rate = FixRatio(32000, 1);
SCSetInfo(ci, scSoundSampleRateType, &rate);
sSize = 8;
SCSetInfo(ci, scSoundSampleSizeType, &sSize);
cCount = 1;
SCSetInfo(ci, scSoundChannelCountType, &cCount);
compType = kMACE6Compression;
SCSetInfo(ci, scSoundCompressionType, &compType);

It is sometimes necessary to restrict the list of compression types appearing in the compression menu. For example, some clients may not support generation of compressed data. The standard sound dialog component allows the client to provide a list of compression types that should be displayed. In the example in Listing 3 , all compression types except for uncompressed are eliminated from the list.

Listing 3 Restricting the list of compression types

Handle compressionTypeList;
compressionTypeList = NewHandle(sizeof(OSType));
**(OSType **)compressionTypeList = kRawCodecType;
SCSetInfo(ci, scCompressionListType, &compressionTypeList);

To display the dialog box, use SCRequestImageSettings as shown in Listing 4 . If the user cancels the dialog box, userCanceledErr is returned.

Listing 4 Displaying the dialog box

OSErr err;
err = SCRequestImageSettings(ci);

After the dialog box has been displayed, the settings can be retrieved using the SCGetInfo call with the appropriate selectors. The example in Listing 5 shows how to retrieve the selected sample rate, sample size, compression format, and number of channels.

Listing 5 Retrieving settings from the dialog box

UnsignedFixed       rate;
short               sSize, cCount;
OSType              compType;

SCGetInfo(ci, scSoundSampleRateType, &rate);
SCGetInfo(ci, scSoundSampleSizeType, &sSize);
SCGetInfo(ci, scSoundChannelCountType, &cCount);
SCGetInfo(ci, scSoundCompressionType, &compType);

It is also possible to retrieve all of the current settings in a single handle, as shown in the next example. This can be convenient when saving user settings:

Handle h;
SCGetInfo(ci, scSettingsStateType, &h);

Once the settings have been retrieved in the handle, they can be restored using SCSetInfo , as follows:

SCSetInfo(ci, scSettingsStateType, &h);

When you are finished with the standard sound dialog component, close the connection to the component as follows:

CloseComponent(ci);

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |